package com.qst.service.impl;

import com.qst.bean.ProductModel;
import com.qst.service.IProductService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Service
public class ProductServiceImpl implements IProductService {

    @Override
    public ProductModel getProductById(Long id) {

        ProductModel productModel = new ProductModel();
        productModel.setId(id);
        productModel.setPrice(new BigDecimal("100.00"));
        productModel.setProductName("测试商品");
        productModel.setNum(100);
        return productModel;
    }

    @Override
    public Boolean addProduct(ProductModel productModel) {
        ProductModel productModel1 = new ProductModel();
        productModel1.setId(productModel.getId());
        productModel1.setPrice(productModel.getPrice());
        productModel1.setProductName(productModel.getProductName());
        productModel1.setNum(productModel.getNum());

        return true;
    }

    public List<ProductModel> getAllProducts(){
        List<ProductModel> productModels = new ArrayList<>();
        ProductModel productModel1 = new ProductModel();
        productModel1.setId(productModel1.getId());
        productModel1.setPrice(productModel1.getPrice());
        productModel1.setProductName(productModel1.getProductName());
        productModel1.setNum(productModel1.getNum());
        productModels.add(productModel1);
        return productModels;

    }

}
